#include <joyos.h>
#include <happylib.h>

#include "define.h"
#include "robomove.h"

/**
 * "blinkLED" controls decoration LEDs to blink
 * LEDs uses a motor port to activate blinking
 *
 * @requires none
 * @effects the attached LEDs are blinked
 * @modifies none
 */
int blinkLED(void){

	int16_t i = 250;
	int16_t count = 0;
	
	motorSetVel(MOTOR_PORT_TOWER, 255);
	
	while(count < 1200){
		if (count > 100) {motor_brake(MOTOR_PORT_TOWER);}
		motorSetVel(MOTOR_PORT_LED, i);
		//motorSetVel(MOTOR_PORT_TOWER, -255);
		i += 50;;
		if (i>250) { i = -250;}
		pause(500);
		yield();
		count++;
	}
	return 0;
}

/**
 * "fantasy" creates a thread for artistic decoration for the robot
 *
 * @requires none
 * @effects decoration thread(s) is(are) activated
 * @modifies none
 */
void fantasy(void){
	int (*blinkpt)(void) = blinkLED;
	create_thread(blinkpt, 1000, 255, "Blink");
}
